﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using JXMSTC2.Model;
using JXMSTC2.Control;

public partial class InfoManage_UserControl_cEduMaterialList : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        EduMaterialModelControl pagegeter = new EduMaterialModelControl();
        int ipagenumber = pagegeter.GetList().Tables[0].Rows.Count;
        pager.RecordCount = ipagenumber;
        BindGridView();
    }


    #region 页面控件的方法
    /// <summary>
    /// 页面编号更改激发的事件
    /// </summary>
    /// <param name="src"></param>
    /// <param name="e"></param>
    protected void pager_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
    {
        pager.CurrentPageIndex = e.NewPageIndex;
        BindGridView();
    }
    #endregion

    #region 显示列表的数据绑定
    /// <summary>
    /// 数据绑定
    /// </summary>
    public void BindGridView()
    {
        string where = "";
        this.grvActivityList.DataSource = DbHelperSQL.GetPagenumberData(pager, "EduMaterial", "Pk_EduMaterialId", "Pk_EduMaterialId desc", "*", where, Convert.DBNull.ToString(), labPager);
        this.grvActivityList.DataBind();

        ////2007年11月4日 测试输入数据 结果：失败 原因：输出参数未能正确获得
        //JXMSTC2.Model.EduMaterial tt = new EduMaterial();
        //int i = 0;
        //tt.Pk_EduMaterialId = i;
        //tt.ClassName = "首期高校IT人才实训教师培训班";
        //tt.EduMaterialBrief = "江西微软技术中心举办首期高校IT人才实训教师培训班";
        //tt.NumOfLessons = 20;
        //tt.OpeningDate = DateTime.Today;
        //tt.CloingDate = DateTime.Today.AddDays(18);
        //tt.ClickTimes = 200;
        ////

        //JXMSTC2.Control.EduMaterialModelControl test = new EduMaterialModelControl();
        //i = test.Add(tt);
        ////
    }
    #endregion

    #region 列表的行命令方法
    /// <summary>
    /// 列表的行命令方法
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grvActivityList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "DeleteInfo")
        {
            EduMaterialModelControl clsact = new EduMaterialModelControl();
            clsact.Delete(int.Parse(e.CommandArgument.ToString()));
            MessageBox.ShowAndRedirect(Page, "信息删除成功", "EduMaterialList.aspx");
        }
    }
    #endregion
}
